import os

from selenium import webdriver


option = webdriver.ChromeOptions()
# 获取用户文件路径
userfile = os.environ["USERPROFILE"]

# 添加用户文件配置
# 使用缓存，也使用了cookie
option.add_argument("--user-data-dir=%s\\AppData\\Local\\Google\\Chrome\\user data"
                    % userfile)
# 配置chrome安装路径
# option.binary_location = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"

# 打开浏览器
# driver就相当于打开的浏览器

driver = webdriver.Chrome(options=option, executable_path='../lib/conf/chromedriver.exe')
driver.implicitly_wait(10)
driver.get("http://testingedu.com.cn:8000/index.php/Home/user/login.html")
ele = driver.find_element_by_xpath('//*[@id="verify_code_img"]')
ele.screenshot('../lib/verify/verify.png')

from common.verify import Verify
ver = Verify('wuqingfqng', '6e8ebd2e301f3d5331e1e230ff3f3ca5', '96001')
print(ver.PostPic(1902,im="../lib/verify/verify.png"))


